home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_07_02 / v7n2072a.txt < prev    next >
Text File  |  1988-12-10  |  2KB  |  63 lines

  1.  
  2. ========
  3. FIGURE 2
  4. ========
  5.  
  6. getl()
  7. {
  8.         if (length == 1)  {
  9.                 /* rule 1 */
  10.                 addch(c):refresh();
  11.                 str[i] = c;
  12.                 break;
  13.         }
  14.         else {
  15.                 if (c == '\n')  {
  16.                         /* rule 2 */
  17.                         break;
  18.                 }
  19.                 else {
  20.                         if (c == BACKSPACE)  {
  21.                                 if (i == 0)  {
  22.                                         /* rule 3 */
  23.                                         beep();
  24.                                 }
  25.                                 else {
  26.                                         /* rule 4 */
  27.                                         backup(1);
  28.                                 }
  29.                         }
  30.                         else {
  31.                                 if (i == length)  {
  32.                                         /* rule 5 */
  33.                                         beep();
  34.                                 }
  35.                                 else {
  36.                                         if (typ == NUMERIC)  {
  37.                                                 if (isdigit(c))  {
  38.                                                         /* rule 6 */
  39.                                                         addch(c):refresh();
  40.                                                         str[i] = c;
  41.                                                         str[i+1] = 0;
  42.                                                         i++;
  43.                                                 }
  44.                                                 else {
  45.                                                         /* rule 7 */
  46.                                                         beep();
  47.                                                 }
  48.                                         }
  49.                                         else {
  50.                                                 /* rule 8 */
  51.                                                 addch(c):refresh();
  52.                                                 str[i] = c;
  53.                                                 str[i+1] = 0;
  54.                                                 i++;
  55.                                         }
  56.                                 }
  57.                         }
  58.                 }
  59.         }
  60. }
  61.  
  62.  
  63.